% #### IMPORT DATA
filename = 'link1.stl';
[F, V, C] = rndread(filename);

% #### Create MATLAB model from the import data
clf;
p = patch('faces', F, 'vertices' ,V);
%set(p, 'facec', 'b');              % Set the face color (force it)
set(p, 'facec', 'flat');            % Set the face color flat
set(p, 'FaceVertexCData', C);       % Set the color (from file)
%set(p, 'facealpha',.4)             % Use for transparency
set(p, 'EdgeColor','none');         % Set the edge color
%     set(p, 'EdgeColor',[1 0 0 ]);      % Use to see triangles, if needed.
light                               % add a default light
daspect([1 1 1])                    % Setting the aspect ratio
 
% #### VIEW CONTROL
% view is not good enough
% cam params - used with set and get
%     view(3)                             % Isometric view
%    az = 45; % oz(+) axis rotation, relative to y(-)  
%   el = 45; % (+) above x-y plane, (-) below x-y plane
%     view(az, el);
    
%     xlabel('X'),ylabel('Y'),zlabel('Z')
%     title(['Imported CAD data from ' filename])
%  set(gca, 'Projection', 'perspective') 

set(gca, 'CameraTarget', [0 0 0]);
set(gca, 'CameraTargetMode', 'manual');

get(gca, 'CameraViewAngle')
set(gca, 'CameraViewAngleMode','manual')  % fixed view angle

get(gca, 'Projection')
set(gca, 'CameraPosition', 2*[3, 4, 5]);

drawnow                             % axis manual

% #### PRINT IMAGE
% snapnow 
axis off
saveas(gca, 'image.jpg');  % good! but I only want to see the object
% size of image?
   
% Notes:
% - need 5-6 DOFs to have a complete model fitting
%   + here, if 'CameraTarget' & 'CameraPositon' are used, 6 DOFs are needed

getContourImage();